package megrez.mail.sender.component.template;

import org.springframework.stereotype.Component;

import lombok.RequiredArgsConstructor;
import megrez.mail.sender.common.MailSenderException;
import megrez.mail.sender.domain.MailContentType;

/**
 * 工厂
 * 
 * @author Lucky Yang
 * @since 2.6.9
 */
@Component
@RequiredArgsConstructor
public class TemplateProcessFactory {
    private final ThymeleafTemplateProcess thymeleafTemplateProcess;
    private final TextTemplateProcess textTemplateProcess;
    private final FreemarkerTemplageProcess freemarkerTemplageProcess;
    private final GroovyTemplageProcess groovyTemplageProcess;
    private final Pug4jTemplageProcess pug4jTemplageProcess;

    public TemplateProcess getProcess(final MailContentType type) {
        switch (type) {
            case TEXT:
                return textTemplateProcess;
            case THYMELEAF:
                return thymeleafTemplateProcess;
            case FREEMARKER:
                return freemarkerTemplageProcess;
            case GROOVY:
                return groovyTemplageProcess;
            case PUG4J:
                return pug4jTemplageProcess;
            default:
                throw new MailSenderException("MailConnextType not support: " + type);
        }
    }
}
